package com.edu.base.common.Interceptor;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

  @Autowired
  private AppLoginAuthInterceptor appLoginAuthInterceptor;


  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    List<String> patterns = new ArrayList();
    patterns.add("/webjars/**");
    patterns.add("/druid/**");
    patterns.add("/swagger/**");
    patterns.add("/v2/api-docs");
    patterns.add("/swagger-ui.html");
    patterns.add("/swagger-resources/**");
    patterns.add("/api/appUser/*");

    registry.addInterceptor(appLoginAuthInterceptor)
        .addPathPatterns("/api/**")
        .excludePathPatterns(patterns);

  }
}
